<?php
header("Access-Control-Allow-Origin:*");
// 文件上传 php 相关代码
$path = "D:/wbs20101/uploads/";
$newName = time() . mt_rand(1000, 9999) . $_FILES["headImage"]["name"];

// 移动文件到指定位置
move_uploaded_file($_FILES["headImage"]["tmp_name"], $path . $newName);

// 返回 通过网络访问该图片的 url
$result = [
    "state"=>true,
    "msg"=>"上传成功",
    "path"=>"http://127.0.0.1:80/uploads/" . $newName
];

echo json_encode($result);
?>